LIST = [
    [0, 0, 1, 1, 0],
    [1, 1, 0, 0, 1],
    [0, 1, 1, 0, 0],
    [0, 0, 0, 1, 0],
    [0, 1, 0, 0, 1]
]
def find(a, LIST, deep):
    if len(a)==5:
        return a
    for i in range(deep, len(LIST)):
        for j in range(len(LIST[i])):
            if LIST[i][j] == 1 and (j not in a):
                a = find(a+[j], LIST, deep+1)
                if len(a)==5:
                    return a

    return a[:]

a = (find([], LIST, 0))
for i in a:
    print(i + 1)
